<style>
.tginput{
    margin-top:10px;
    margin-bottom:10px;
    padding-left:19px;
    background:none repeat scroll 0 0 #FAFAFA;
    border:1px solid #cccccc;
    color:#069CBC;
    font-size:20px;
    line-height:30px;
    height:35px;
    width: 400px;
}
.tgbutton{
    margin-top: -10px;
    margin-left: 25px;
    font-size:1.5em;

    height: 39px; 
    width:100px;
    cursor:pointer;
    display:-moz-inline-stack;
    line-height: 35px;
    overflow: visible;
    text-decoration: none;
    vertical-align: middle;
}
</style>
<div class="tableform">
<form action="index.php?app=console&ctl=admin_stock&act=search" id="formid" method="post">
<h3>基础物料库存查询</h3>
<div class="division">
<table>
    <tr>
        <td>
          <div style="position:relative">
            <input type="text" id="stock_search" name="stock_search" class="tginput" value="<{$keywords}>" />
            <button type="submit" id="btn_search" class='tgbutton'><span><span>查询</span></span></button>(请录入基础物料编码、名称或条码进行查询)
        </td>
    </tr>
</table>
</div>

<div class="division">
<table class="gridlist" cellpadding="0" cellspacing="0">
    <thead>
        <tr>
            <th>基础物料编码</th>
            <th style='text-align:left;'>基础物料名称</th>
            <th>条形码</th>
            <th>规格</th>
            <th>仓库名</th>
            <th>货位</th>
            <th style="display:none;">数量(最大/实际)</th>
            <th>实际库存</th>
        </tr>
    </thead>
    <{if $data}>
    <tbody>
    <{foreach from=$data item=product}>
      <tr>
        <td><{$product.bn}></td>
        <td style='text-align:left;'><{$product.name|visibility:$product.product_id}></td>
        <td><{$product.barcode}></td>
        <td><{$product.spec_info|default:'-'}></td>
        <td><{$product.branch|default:'-'}></td>
        <td><{$product.store_position|default:'-'}></td>
        <td style="display:none;"><{$product.max_store|default:0}>/<{$product.store|default:0}></td>
        <td><{$product.store|default:0}></td>
      </tr>
    <{/foreach}>
    </tbody>
    <{/if}>
</table>
</div>
</form>
</div>
<script>
$('stock_search').focus();
(function(){
    new Autocompleter.script($E('#stock_search'),"index.php?app=console&ctl=admin_stock&act=getProductsByAuto", {
        'getVar':'stock_search',
        'fxOptions':false,
        callJSON:function(){return window.autocompleter_json;},
        injectChoice:function(json){
            var choice = new Element('li', {'html': this.markQueryValue(json[this.options.getVar])});
            choice.inputValue = json[this.options.getVar];
            this.addChoiceEvents(choice).inject(this.choices);
        }
    });
})();
function visibility(e){
    var visiTips = new Tips({
            onShow:function(tip,el){
                el.addClass('active');
                tip.setStyle('display','block');
            },
            text: function(element){
                if(element.get('visibility')=='false'){
                    return '不可售商品';
                }else{
                    return '';
                }
            }
        });

        var e  = new Event(e), el = e.target;
        if (el.get('visibility')=='false')
        {
            visiTips.attach(el);
            el.addEvent('mouseleave',function(){
                el.removeClass('active');
            });
            el.fireEvent('mouseenter',e);
        }
}
</script>